
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;

namespace Ciloci.Flee
{

    // This library is free software; you can redistribute it and/or
    // modify it under the terms of the GNU Lesser General Public License
    // as published by the Free Software Foundation; either version 2.1
    // of the License, or (at your option) any later version.
    // 
    // This library is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    // Lesser General Public License for more details.
    // 
    // You should have received a copy of the GNU Lesser General Public
    // License along with this library; if not, write to the Free
    // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    // MA 02111-1307, USA.
    // 
    // Flee# - A port of Eugene Ciloci's Flee to C#
    // Copyright © 2012 Yoni Gozman
    //

	// Base class for an expression element that operates on one value
	internal abstract class UnaryElement : ExpressionElement
	{

		protected ExpressionElement MyChild;

		private Type MyResultType;
		public void SetChild(ExpressionElement child)
		{
			MyChild = child;
			MyResultType = this.GetResultType(child.ResultType);

			if (MyResultType == null) {
				base.ThrowCompileException(CompileErrorResourceKeys.OperationNotDefinedForType, CompileExceptionReason.TypeMismatch, MyChild.ResultType.Name);
			}
		}

		protected abstract Type GetResultType(Type childType);

		public override System.Type ResultType {
			get { return MyResultType; }
		}
	}
}
